﻿<UserControl x:Class="Intel.LocalHistory.LocalHistoryControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="300"
    Name="LocalHistoryToolWindow">

  <UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

    <Style x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem">
      <EventSetter Event="MouseDoubleClick" Handler="MouseDoubleClickHandler" />
      <Setter Property="SnapsToDevicePixels" Value="true"/>
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="ListBoxItem">
            <StackPanel Name="Panel" HorizontalAlignment="Stretch" Orientation="Horizontal" >
              <Label Name="Label" HorizontalAlignment="Stretch"
                   Content="{Binding TimeStamp}"
                   Foreground="{DynamicResource {x:Static vsui:TreeViewColors.SelectedItemInactiveTextBrushKey}}"></Label>
            </StackPanel>
            <ControlTemplate.Triggers>
              <MultiTrigger>
                <MultiTrigger.Conditions>
                  <Condition Property="IsFocused" Value="False"/>
                  <Condition Property="IsSelected" Value="False"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                  <Setter TargetName="Panel" Property="Background"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.BackgroundBrushKey}}"/>
                  <Setter TargetName="Label" Property="Foreground"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.BackgroundTextBrushKey}}"/>
                </MultiTrigger.Setters>
              </MultiTrigger>
              <MultiTrigger>
                <MultiTrigger.Conditions>
                  <Condition Property="IsFocused" Value="True"/>
                  <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                  <Setter TargetName="Panel" Property="Background"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.SelectedItemActiveBrushKey}}"/>
                  <Setter TargetName="Label" Property="Foreground"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.SelectedItemActiveTextBrushKey}}"/>
                </MultiTrigger.Setters>
              </MultiTrigger>
              <MultiTrigger>
                <MultiTrigger.Conditions>
                  <Condition Property="IsFocused" Value="False"/>
                  <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                  <Setter TargetName="Panel" Property="Background"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.SelectedItemInactiveBrushKey}}"/>
                  <Setter TargetName="Label" Property="Foreground"
                    Value="{DynamicResource {x:Static vsui:TreeViewColors.SelectedItemInactiveTextBrushKey}}"/>
                </MultiTrigger.Setters>
              </MultiTrigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </UserControl.Resources>

  <Grid>
    <Label
        Background="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowBackgroundBrushKey}}"
        Foreground="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowTextBrushKey}}"
        BorderBrush="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowBorderBrushKey}}"
        Content="No History"></Label>
    <ListBox
        x:Name="DocumentListBox"
        Background="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowBackgroundBrushKey}}"
        Foreground="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowTextBrushKey}}"
        BorderBrush="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowBorderBrushKey}}"
        ItemsSource="{Binding DocumentItems}"
        Visibility="{Binding HasHistory, Converter={StaticResource BooleanToVisibilityConverter}}">
    </ListBox>
  </Grid>
</UserControl>
